var newsPager = new vo.newObj({
	el:'#news',
	datas:{
		offset:-1,
		size:5,
		content:'',
	},
	methods:{
		loadPager:function(){
			ajax({
				method:'GET',
				url:'sysnews/'+blog.id,
				datas:{size:this.get('size'),offset:this.get('offset')},
				success:function(response){
					var datas = response.datas;
					var offset = datas.offset;
					var size = datas.size;
					datas = datas.datas;
					var content = "";
					var tail = "";
					if(typeof(datas) != 'undefined'){
						for(var i = size;i--;i>=0){
							content += news(datas[i]);
						}
						tail = "<div class='more' style='border-radius:5px' >"+
						"<div class='msg-more' vo-m='click:loadPager'>显示更多</div>" +
						"</div>";
						
					}
					content = newsPager.get("content") + content;
					if(content == ""){
						content = "<div class='info'>"+
    					"<span>暂时没有新动态</span>"+
	    				"</div>";
					}
					newsPager.setDatas({
						size:size,
						offset:offset,
						loading:'',
						content:content,
						tail:tail
					});
					newsPager.flush();
					newsPager.bindMethod();
				},
				error:function(datas){
					var message = "数据加载失败";
					throw new Error(message);
					newsPager.setDatas({loading:message});
					newsPager.flush();
				}
			});
		}
	}
});
newsPager.methods.loadPager();
var news = function(){
	var news = "<div class='dl-tag'>" +
				"<span class='point'></span>" +
				"<div class='line-border opacity'></div>" +
				"<span class='dl-msg'>${message}:<a href='${target}'>${title}</a></span>"+
				"<span class='content'>${content}</span>"+
				"<span class='time'>${createTime}</span>"+
				"</div>";
	function createNews(data){
		var copy = news;
		var reg = new RegExp("\\${(\\w+)}?","g");
		var result = copy.replace(reg,function($0,$1){
			if($1 == "message"){
				if(data.type == 0){
					return "发布了博客";
				}else if(data.type == 1){
					return "更新了日志";
				}else if(data.type == 2){
					return "评论了博客";
				}else if(data.type == 3){
					return "收藏了网摘";
				}
			}else if($1 == "createTime"){
				return typeof(data[$1]) == 'undefined'?"":
					new Date(parseInt(data[$1])).toLocaleString().replace(/:\d{1,2}$/,'');
			}else{
				return typeof(data[$1])=='undefined'?"":data[$1];
			}
		});
		return result;
	}
	return createNews;
}();